package com.example.demo.mapper;

import com.example.demo.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.vo.Roommate;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author chen huilong
 * @since 2022-10-04
 */
public interface UserMapper extends BaseMapper<User> {


    @Select("<script>"
            + "SELECT * "
            + "FROM user "
            + "where user_number in"
            + " <foreach collection='studentNums' item='studentNum' index='index'  open='(' close=')' separator=','>"
            + " #{studentNum} "
            + " </foreach>"
            + "</script>")
    List<User> selectListByNums(@Param("studentNums") List<Long> studentNums);

    @Select("SELECT * FROM user")
    List<User> selectLists();


    @Select("<script>"
            + "SELECT user_number, user_name, email, phonenumber "
            + "FROM user "
            + "where room_id = "
            + "#{roomId}"
            + "</script>")
    List<Roommate> selectListByRoomId(@Param("roomId") String roomId);
}
